package com.example.finalwork06.Service.Impl;

import com.example.finalwork06.Entity.ChinaIndex;
import com.example.finalwork06.Entity.PageBean;
import com.example.finalwork06.Mapper.ChinaIndexMapper;
import com.example.finalwork06.Service.ChinaIndexService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ChinaIndexServiceImpl implements ChinaIndexService {
    @Autowired
    private ChinaIndexMapper chinaIndexMapper;

    @Override
    public PageBean page(Integer page, Integer pageSize) {
        //1.设置分页参数
        PageHelper.startPage(page,pageSize);
        //2.查询
        List<ChinaIndex> List=chinaIndexMapper.list();
        Page<ChinaIndex> p=(Page<ChinaIndex>) List;
        //3.封装
        PageBean pageBean=new PageBean(p.getTotal(),p.getResult());
        return pageBean;
    }
}
